#include <bits/stdc++.h>
// 2025/01/19
// tag: recursion
// Author: Zhang Muen
using namespace std;

#define int long long
#define F1 (x - a <= l / 2 - 1)
#define F2 (y - b <= l / 2 - 1)

int x, y, len, k;

void solve(int x, int y, int a, int b, int l){
    if (l == 1)
        return;
    if (F1 && F2){ //
        cout << a + l / 2 << " " << b + l / 2 << " 1" << endl;
        solve(x, y, a, b, l / 2);
        solve(a + l / 2 - 1, b + l / 2, a, b + l / 2, l / 2);
        solve(a + l / 2, b + l / 2 - 1, a + l / 2, b, l / 2);
        solve(a + l / 2, b + l / 2, a + l / 2, b + l / 2, l / 2);
    }
    else if (F1 && !F2){//
        cout << a + l / 2 << " " << b + l / 2 - 1 << " 2" << endl;
        solve(a + l / 2 - 1, b + l / 2 - 1, a, b, l / 2);
        solve(x, y, a, b + l / 2, l / 2);
        solve(a + l / 2, b + l / 2 - 1, a + l / 2, b, l / 2);
        solve(a + l / 2, b + l / 2, a + l / 2, b + l / 2, l / 2);
    }
    else if (!F1 && F2){ //
        cout << a + l / 2 - 1 << " " << b + l / 2 << " 3" << endl;
        solve(a + l / 2 - 1, b + l / 2 - 1, a, b, l / 2);
        solve(a + l / 2 - 1, b + l / 2, a, b + l / 2, l / 2);
        solve(x, y, a + l / 2, b, l / 2);
        solve(a + l / 2, b + l / 2, a + l / 2, b + l / 2, l / 2);
    }
    else{
        cout << a + l / 2 - 1 << " " << b + l / 2 - 1 << " 4" << endl;
        solve(a + l / 2 - 1, b + l / 2 - 1, a, b, l / 2);
        solve(a + l / 2 - 1, b + l / 2, a, b + l / 2, l / 2);
        solve(a + l / 2, b + l / 2 - 1, a + l / 2, b, l / 2);
        solve(x, y, a + l / 2, b + l / 2, l / 2);
    }
}

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> k >> x >> y;
    len = 1LL << k;
    solve(x, y, 1, 1, len);
    return 0;
}